import request from '@/utils/request'

// 创建文章
export function createArticle(data) {
  return request({
    url: '/article/create',
    method: 'post',
    data
  })
}

// 更新文章
export function updateArticle(data) {
  return request({
    url: '/article/update',
    method: 'put',
    data
  })
}

// 删除文章
export function deleteArticle(articleId) {
  return request({
    url: `/article/${articleId}`,
    method: 'delete'
  })
}

// 获取文章详情
export function getArticleDetail(articleId) {
  return request({
    url: `/article/${articleId}`,
    method: 'get'
  })
}

// 获取文章列表
export function getArticleList(data) {
  return request({
    url: '/article/list',
    method: 'post',
    data
  })
}

// 点赞/取消点赞文章
export function toggleLikeArticle(articleId) {
  return request({
    url: `/article/${articleId}/like`,
    method: 'post'
  })
}

// 收藏/取消收藏文章
export function toggleCollectArticle(articleId) {
  return request({
    url: `/article/${articleId}/collect`,
    method: 'post'
  })
}

// 发布文章
export function publishArticle(articleId) {
  return request({
    url: `/article/${articleId}/publish`,
    method: 'post'
  })
}
